function result = predictImage(type, model, path, k, T)
    % PREDICTIMAGE   use svmpredict on single image.
    % RESULT = PREDICTIMAGE(TYPE, MODEL, PATH, K, T) where MODEL is the 
    % SVM model for predict, and PATH is the path to the image file.
    % The return value RESULT includes labels and decision_values 
    % from SVMPREDICT.
    % TYPE is one of the following value:
    %   '1', '2', 'all'
    % see help HIST for more information.
    %
    
    if nargin < 5
        T = 4;
    end
    if nargin < 4
        k = 10;
    end
    img = jpeg_read(path);
    switch type
        case '1'
            h=generateHist(img.coef_arrays{1}, k);
        case '2'
            h=generateDiff2DHist(img.coef_arrays{1}, T);
        case 'all'
            h=[generateHist(img.coef_arrays{1}, k), ...
                generateDiff2DHist(img.coef_arrays{1}, T)];
    end
    [label, accuracy, decision_value] = svmpredict(-1, h, model);
    result = [label, decision_value];
end

